ff04eead91c6863968f3f5b8aede56e55f2cfa9b
[openwrt/openwrt.git] /
1 From 0d1d165eff9d6cfad51113e18d9d8c9a8de27d6d Mon Sep 17 00:00:00 2001
2 From: Bitterblue Smith <rtl8821cerfe2@gmail.com>
3 Date: Sun, 26 Jan 2025 16:04:21 +0200
4 Subject: [PATCH] wifi: rtw88: Don't use static local variable in
5 rtw8821c_set_tx_power_index_by_rate
6
7 Some users want to plug two identical USB devices at the same time.
8 This static variable could theoretically cause them to use incorrect
9 TX power values.
10
11 Move the variable to the caller and pass a pointer to it to
12 rtw8821c_set_tx_power_index_by_rate().
13
14 Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
15 Acked-by: Ping-Ke Shih <pkshih@realtek.com>
16 Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
17 Link: https://patch.msgid.link/fe42858c-9b9f-4f03-9aaa-737472c2cd90@gmail.com
18 ---
19 drivers/net/wireless/realtek/rtw88/rtw8821c.c | 14 ++++++++------
20 1 file changed, 8 insertions(+), 6 deletions(-)
21
22 --- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c
23 +++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c
24 @@ -680,11 +680,11 @@ static void query_phy_status(struct rtw_
25 }
26
27 static void
28 -rtw8821c_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs)
29 +rtw8821c_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path,
30 + u8 rs, u32 *phy_pwr_idx)
31 {
32 struct rtw_hal *hal = &rtwdev->hal;
33 static const u32 offset_txagc[2] = {0x1d00, 0x1d80};
34 - static u32 phy_pwr_idx;
35 u8 rate, rate_idx, pwr_index, shift;
36 int j;
37
38 @@ -692,12 +692,12 @@ rtw8821c_set_tx_power_index_by_rate(stru
39 rate = rtw_rate_section[rs][j];
40 pwr_index = hal->tx_pwr_tbl[path][rate];
41 shift = rate & 0x3;
42 - phy_pwr_idx |= ((u32)pwr_index << (shift * 8));
43 + *phy_pwr_idx |= ((u32)pwr_index << (shift * 8));
44 if (shift == 0x3 || rate == DESC_RATEVHT1SS_MCS9) {
45 rate_idx = rate & 0xfc;
46 rtw_write32(rtwdev, offset_txagc[path] + rate_idx,
47 - phy_pwr_idx);
48 - phy_pwr_idx = 0;
49 + *phy_pwr_idx);
50 + *phy_pwr_idx = 0;
51 }
52 }
53 }
54 @@ -705,6 +705,7 @@ rtw8821c_set_tx_power_index_by_rate(stru
55 static void rtw8821c_set_tx_power_index(struct rtw_dev *rtwdev)
56 {
57 struct rtw_hal *hal = &rtwdev->hal;
58 + u32 phy_pwr_idx = 0;
59 int rs, path;
60
61 for (path = 0; path < hal->rf_path_num; path++) {
62 @@ -712,7 +713,8 @@ static void rtw8821c_set_tx_power_index(
63 if (rs == RTW_RATE_SECTION_HT_2S ||
64 rs == RTW_RATE_SECTION_VHT_2S)
65 continue;
66 - rtw8821c_set_tx_power_index_by_rate(rtwdev, path, rs);
67 + rtw8821c_set_tx_power_index_by_rate(rtwdev, path, rs,
68 + &phy_pwr_idx);
69 }
70 }
71 }